package com.javastudy.thread.model;

public class StopThread extends Thread {
    private int i = 0 , j = 0;

    @Override
    public void run() {
        synchronized (this){
            //增加同步锁，确保线程安全
            ++ i;
            try {
                //休眠10秒，模拟耗时操作
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            ++ j;
        }
    }

    @Override
    public String toString() {
        return "StopThread{" +
                "i=" + i +
                ", j=" + j +
                '}';
    }
}
